﻿$(document).ready(function () {
    lblKeyid.SetText($.query.get('Keyid'));
    txtRoleCode.SetText($.query.get('RoleCode'));
    txtRoleName.SetText($.query.get('RoleName'));
    txtRoleCode.SetEnabled(false);
    txtRoleName.SetEnabled(false);
});

//选择模块
var doSelectedIndexChanged = function (s, e) {
    //    var keyid = s.GetSelectedItem().value;
    //    if (keyid == 'none') {
    //        $('#hfModuleFilterCondition').val('');
    //    } else {
    //        $('#hfModuleFilterCondition').val('Keyid=' + keyid);
    //    }
    //    gvwPageList.PerformCallback();
}

//分配页面
var doCheckedChanged_Page = function (s, e) {
    var isSelected = s.GetChecked();
    var obj = s.GetMainElement();
    var pageKeyid = $('> .keyidField', obj.parentNode).text();

    SGDemo.Permission.AssociatedPagesAndButtons.CheckedChangedPage(lblKeyid.GetText(), pageKeyid, isSelected, function (result) {
        if (result.value) {
            $.messager.show({
                title: '信息提示',
                msg: '操作成功!'
            });
        } else {
            $.messager.show({
                title: '信息提示',
                msg: '操作失败!'
            });
        }
    });
}
//双击页面列表GridView行
var doRowDblClick = function (s, e) {
    var keyid = s.GetRowKey(e.visibleIndex)
    $('#hfButtonFilterCondition').val(keyid);
    gvwButtonList.PerformCallback();
    //设置按钮列表面板HeaderText
    s.GetRowValues(e.visibleIndex, 'Name', function (result) {
        rpButton.SetHeaderText('按钮列表-' + result.toString());
    });
}
//分配按钮
var doCheckedChanged_Button = function (s, e) {
    var isSelected = s.GetChecked();
    var obj = s.GetMainElement();
    var buttonKeyid = $('> .keyidField', obj.parentNode).text();

    SGDemo.Permission.AssociatedPagesAndButtons.CheckedChangedButton(lblKeyid.GetText(), buttonKeyid, isSelected, function (result) {
        if (result.value) {
            $.messager.show({
                title: '信息提示',
                msg: '操作成功!'
            });
        } else {
            $.messager.show({
                title: '信息提示',
                msg: '操作失败!'
            });
        }
    });
}

var cbChoose_click = function (s, e) {
    if (s.GetChecked()) {

        gvwButtonList.SelectAllRowsOnPage(s.GetChecked());


        //        for (var i = 0; i < gvwButtonList.GetPageCount(); i++)
        //            cbSelectButtonItem[i].Checked = s.GetChecked();

    }


}

var doSearch = function () {
    var result = '';
    var keyWords = txtKeyWords.GetText();
    if (keyWords) {
        result = 'KeyWords=' + keyWords + '&';
    } else {
        result = 'KeyWords=&';
    }

    var keyid = cbModule.GetSelectedItem().value;

    if (keyid == 'none') {
        result += 'Keyid=';
    } else {
        result += 'Keyid=' + keyid;
    }

    $('#hfModuleFilterCondition').val(result);
    gvwPageList.PerformCallback();

}
